﻿using System.Management;

namespace Aspects.Custom
{
    class WmiProperty
    {
        public static string GetProperty(string wmiClass, string qualifier, string desiredProperty)
        {
            try
            {
                var searchString = @"\\.\root\cimv2:";
                searchString += wmiClass;
                searchString += "='";
                searchString += qualifier;
                searchString += "'";
                var management = new ManagementObject(searchString);
                return management[desiredProperty].ToString();
            }
            catch
            {
                return null;
            }
        }
    }
}
